#ifndef EYERWANDARTIST_EWAPRJTIMELINE_HPP
#define EYERWANDARTIST_EWAPRJTIMELINE_HPP

#include <vector>

#include "EyerCore/EyerCore.hpp"

#include "EWAPrjTrack.hpp"
#include "EWAPrjTrackType.hpp"

namespace Eyer
{
    class EWAPrjTimeline;

    class EWAPrjTimelineListener
    {
    public:
        virtual int OnTrackUpdate(EWAPrjTimeline * timeline) = 0;
    };

    typedef std::vector<EyerSmartPtr<EWAPrjTrack>> TrackList;

    class EWAPrjTimeline
    {
    public:
        EWAPrjTimeline();
        ~EWAPrjTimeline();

        int GetTrackCount(const EWAPrjTrackType & type);
        EyerSmartPtr<EWAPrjTrack> GetTrack(int index, const EWAPrjTrackType & type);

        int AddTrack(const EyerSmartPtr<EWAPrjTrack> & track, int index, const EWAPrjTrackType & type);
        int AddTrackBack(const EyerSmartPtr<EWAPrjTrack> & track, const EWAPrjTrackType & type);

        int Parse(const EyerString & json);
        const EyerString Serializable();

        int RegisterListener(EWAPrjTimelineListener * listener);
        int UnregisterListener(EWAPrjTimelineListener * listener);

        int RegisterTrackListener(EWAPrjTrackListener * listener);
        int UnregisterTrackListener(EWAPrjTrackListener * listener);

    private:
        std::map<EWAPrjTrackType, EyerSmartPtr<TrackList>> trackSet;

        std::vector<EWAPrjTimelineListener *> listenerList;
        int Update();

        std::vector<EWAPrjTrackListener *> trackListenerList;
    };
}

#endif //EYERWANDARTIST_EWAPRJTIMELINE_HPP
